<%@page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Main</title>
<style type="text/css">
	tr{height:30px;}
	td{padding: 10px;}
</style>
</head>
<body>
	<%--
		//判断用户是否登入
		String username = (String)request.getSession().getAttribute("user");
		if(username==null || "".equals(username)) {
			response.sendRedirect(request.getContextPath()+"/login.jsp");
		}
	--%>
	
	<%-- 判断用户是否登入的 jstl 代码 --%>
	<%-- <c:if test="${empty sessionScope.user }">
		<c:redirect url="/login.jsp" />
	</c:if> --%>
	
	<form action="<%=request.getContextPath()%>/query.udo" method="post">
		<table style="margin:20px auto; padding: 50px; border: 1px #ccc solid; width: 400px; text-align: center;">
			<tr>
				<td style="text-align: right;">用户名：</td>
				<td style="text-align: left;"><input type="text" name="username"></td>
			</tr>
			<tr>
				<td style="text-align: right;">用户地址：</td>
				<td style="text-align: left;"><input type="text" name="address"></td>
			</tr>
			<tr>
				<td style="text-align: right;">用户电话：</td>
				<td style="text-align: left;"><input type="text" name="phoneNum"></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;"><input type="Submit" value="查询用户"></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;"><a href="<%=request.getContextPath()%>/add.jsp">注册新用户</a></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;"><a href="<%=request.getContextPath()%>/logout.udo">注销登入</a></td>
			</tr>
		</table>
	</form>

	<table style="text-align: center; margin:20px auto; padding: 50px" border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td>用户id</td>
			<td>用户名</td>
			<td>用户密码</td>
			<td>用户电话</td>
			<td>用户地址</td>
			<td>注册日期</td>
			<td>操作记录</td>
		</tr>
		
		<c:if test="${not empty userList }">
			<c:forEach items="${userList }" var="user">
			<tr>
				<td>${user.id }</td>
				<td>${user.username }</td>
				<td>${user.password }</td>
				<td>${user.phoneNum }</td>
				<td>${user.address }</td>
				<td>${user.regDate }</td>
				<td><a href="${pageContext.request.contextPath }/update.udo?id=${user.id}">编辑</a>|<a href="${pageContext.request.contextPath }/delete.udo?id=${user.id}">删除</a></td>
			</tr>
			</c:forEach>
		</c:if>				
	</table>
</body>
</html>